<div class="layui-tab layui-tab-card">
    <ul class="layui-tab-title">
      <li class="layui-this">粉丝订单</li>
      <li>粉丝进场数据</li>
      <li>粉丝抢购成功数据</li>
    </ul>
    <div class="layui-tab-content" style="height: 100px;">
      <div class="layui-tab-item layui-show">
        <div class="layui-row">

          当日订单总数：{$count}    
        </div>
        <div class="layui-row">
          当日订单总金额：{$total}

        </div>

        <table class="layui-table">
          <colgroup>
            <col width="150">
            <col width="200">
            <col>
          </colgroup>
          <thead>
            <tr>
              <th>订单号</th>
              <th>下单时间</th>
              <th>商品价格</th>

              <!--<th>所属总销</th>-->

              <th>商品信息</th>
              <th>买方信息</th>
              <th>卖方信息</th>
              <th>支付凭证</th>
            </tr> 
          </thead>
          <tbody>
              {foreach name="orders" item="item"}
            <tr>
              <td>{$item.order_no}</td>
              <td>{$item.create_time}</td>
              <td>{$item.g_price/100}</td>
              <!--<td></td>-->
              <td><a class="layui-btn layui-btn-xs layui-btn-normal goods" data-goods="{$item.gid}">{$item.goods_name}</a></td>
              <td><a class="layui-btn layui-btn-xs layui-btn-normal buyer" data-buyer="{$item.uid}">{$item.buy_nickname}</a></td>
              <td><a class="layui-btn layui-btn-xs layui-btn-normal saler" data-saler="{$item.saler_id}">{$item.sale_nickname}</a></td>
              <td><a class="layui-btn layui-btn-xs layui-btn-normal view_img" data-id="{$item.id}">查看</a></td>
            </tr>
            {/foreach}

          </tbody>
        </table>
      </div>

      <div class="layui-tab-item">
        <div class="layui-row">
          今日该场次有<span id="jin_num">0</span>人进场    
        </div>
        <div class="layui-row">
          <select name="jin_rush" id="jin_rush">
              <option value="">请选择场次</option>
              {foreach name="bucket" item="buc"}
                <option value="{$buc.id}">{$buc.name}</option>
              {/foreach}
          </select>
        </div>
        <table class="layui-table">
          <thead>
            <tr>
              <th>用户姓名</th>
            </tr> 
          </thead>
          <tbody id="jin">
            
          </tbody>
          </table>
      </div>

      <div class="layui-tab-item">
        <div class="layui-row">
          今日该场次有<span id="buy_num">0</span>人抢购成功   
        </div>
        <div class="layui-row">
          <select name="buyid" id="buyid">
              <option value="">请选择场次</option>
              {foreach name="bucket" item="buc"}
                <option value="{$buc.id}">{$buc.name}</option>
              {/foreach}
          </select>
        </div>
        <table class="layui-table">
          <thead>
            <tr>
              <th>用户姓名</th>
            </tr> 
          </thead>
          <tbody id="buy">
            
          </tbody>
          </table>
      </div>
<input type="hidden" name="user_id" id="user_id" value="{$user_id}">
    </div>
  </div>

<script src="/static/plugs/jquery-3.4.1/jquery-3.4.1.min.js" charset="utf-8"></script>
<script src="/static/plugs/layui-v2.5.6/layui.all.js?v=1667474900" charset="utf-8"></script>
<link id="layuicss-layer" rel="stylesheet" href="/static/plugs/layui-v2.5.6/css/modules/layer/default/layer.css?v=3.1.1" media="all">

<script>
  $('.view_img').click(function(){
        var id = $(this).data("id");
        layui.use('layer', function(){
            var layer = layui.layer;
            layer.open({
            type: 2,
                    title: '查看',
                    area: ['60%', '80%'], //宽高*/
                    maxmin:true,
                    Boolean:1,
                    content: "/admin/usertree/payimg?orderid="+id,
            });
        });
    });

    $('.goods').click(function(){
        var id = $(this).data("goods");
        layui.use('layer', function(){
            var layer = layui.layer;
            layer.open({
            type: 2,
                    title: '查看',
                    area: ['60%', '80%'], //宽高*/
                    maxmin:true,
                    Boolean:1,
                    content: "/admin/usertree/getGoods?goods="+id,
            });
        });
    });

    $('.buyer').click(function(){
        var id = $(this).data("buyer");
        layui.use('layer', function(){
            var layer = layui.layer;
            layer.open({
            type: 2,
                    title: '查看',
                    area: ['60%', '80%'], //宽高*/
                    maxmin:true,
                    Boolean:1,
                    content: "/admin/usertree/getUser?userid="+id,
            });
        });
    });

    $('.saler').click(function(){
        var id = $(this).data("saler");
        layui.use('layer', function(){
            var layer = layui.layer;
            layer.open({
            type: 2,
                    title: '查看',
                    area: ['60%', '80%'], //宽高*/
                    maxmin:true,
                    Boolean:1,
                    content: "/admin/usertree/getUser?userid="+id,
            });
        });
    });

    
    $("#jin_rush").change(function(){
        //$("#jin_num").html("0");
        var jinid = $(this).val();
        $.ajax({
    	url: "/admin/usertree/jinchang",
    	type: "post",
    	dataType: "json",
    	data: {
    	    jinid : jinid,
    	    user_id: $("#user_id").val()
    	},
    	success: function (result) {
    	    $("#jin").html("");
    	    var strs = "";
    	    $("#jin_num").html(result.length);
    	    if(result.length > 0){
        	    for(var i=0; i<= result.length; i++){
        	       strs = "<tr><td>" + result[i].nickname+ "</td></tr>";
        	       $("#jin").append(strs);
    	        }
    	    } else {
    	        strs_null = "<tr><td>暂无数据</td></tr>";
        	    $("#jin").append(strs_null);
    	    }
        }
    })
});
    
    $("#buyid").change(function(){
        //$("#jin_num").html("0");
        var buyid = $(this).val();
        $.ajax({
    	url: "/admin/usertree/buy",
    	type: "post",
    	dataType: "json",
    	data: {
    	    buyid : buyid,
    	    user_id: $("#user_id").val()
    	},
    	success: function (res) {
    	    $("#buy").html("");
    	    var html = "";
    	    $("#buy_num").html(res.length);
    	    if(res.length > 0){
    	        for(var j=0; j<= res.length; j++){
    	       html = "<tr><td>" + res[j].nickname+ "</td></tr>";
    	       $("#buy").append(html);
    	    }
    	    }
    	    
    	}
    })
    });

  </script> 